<?

    require("foundation/fpages_bar.php");
    $recom_rs=array();
    $recom_rs=select_spell('isns_article_news',"*","is_recom=1 and status=1","order_num","asc","getRs",1,"art_news/list/all/recom",10);

    $sql ="SELECT * FROM isns_recommend AS recommend";
    $sql.=" limit 0,9";
    $dbo=new dbex();
    dbtarget('r',$dbServs);
    $user_rs= $dbo->getRs($sql);
 

    $page=$_REQUEST["page"];
    $size=20;
    if(empty($page)){
        $page=1;
    }
    $start=($page-1)*$size;
    $mSql ="SELECT * FROM iweber_message order by iweber_message_time desc";
    $mSql.=" limit $start,$size";
    $message_rs= $dbo->getRs($mSql);

    $cSql="SELECT count(*) FROM iweber_message";
    $count_rs= $dbo->getRs($cSql);
    $all=ceil($count_rs[0][0]/$size);





















function select_spell($table,$fields="*",$condition="1=1",$order_col='',$order='',$get_type="getRs",$cache=0,$cache_key='',$num=''){
	global $page_data_num;
	global $page_num;
	global $page_total;
	global $cachePages;
	$get_type=$get_type ? $get_type:'getRs';
	$page_data_num=$page_data_num ? $page_data_num : 20;
	$order_str='';
	$limit=$num ? " limit $num ":'';
	$result_rs=array();
	$is_perpage=0;
	$dbo=new dbex;
  dbplugin('r');
  $fields=filt_fields($fields);

  if($get_type=='getRs' && intval($num)==0){
  	$is_perpage=1;//判断是否有分页
  }
  
  if($order_col!=''){
	  if(strpos($order_col,',')){
	  	$order_col_array=explode(',',$order_col);
	  	$order_array=explode(',',$order);
	  	$order_str="order by $order_col_array[0] $order_array[0],$order_col_array[1] $order_array[1]";
	  }else{
	  	$order_str="order by $order_col $order";
	  }  	
  }

  $condition=$condition ? $condition:"1=1";
	$sql="select $fields from $table where $condition $order_str";
	
	if($cache==1&&$cache_key!=''&&0){//缓存处理
		if(strpos($order_col,',')){
			$corder_cache = isset($order_col_array[0]) ? '_c['.$order_col_array[0].'_'.$order_col_array[1].']' :'';
			$aorder_cache = isset($order_array[0]) ? '_a['.$order_array[0].'_'.$order_array[1].']':'';
		}else{
			$corder_cache = $order_col ? '_c['.$order_col.']' :'';
			$aorder_cache = $order ? '_a['.$order.']':'';
		}
		$key=$cache_key.$corder_cache.$aorder_cache;
		$key_mt=$cache_key.'_mt';
		
		if($is_perpage==1){//分页缓存处理
			$limit=$limit ? $limit : ' limit '.$cachePages*$page_data_num;
			$sql_limit=$sql.$limit;
			$result_rs_total=model_cache($key,$key_mt,$dbo,$sql_limit,$get_type);
			$page_num = $page_num ? $page_num-1:0;
			$key=$cache_key.$corder_cache.$aorder_cache.'_total';
			$sql_count="select count(*) as total_count ".strstr($sql,"from");//查询总数
			$total_row=model_cache($key,$key_mt,$dbo,$sql_count,"getRow");
			$result_rs_cut=array_chunk($result_rs_total,$page_data_num);
			$result_rs=$result_rs_cut[$page_num];
			$page_total=floor(($total_row['total_count']-1)/$page_data_num)+1;//总页数
		}else{//无分页缓存处理
			$sql_limit=$sql.$limit;
			$result_rs=model_cache($key,$key_mt,$dbo,$sql_limit,$get_type);
		}
	}else{//无缓存处理
		$sql.=$limit;
	}
    
	if(empty($result_rs)){
		if($is_perpage==1){
			$dbo->setPages($page_data_num,$page_num);
			$result_rs=$dbo->getRs($sql);
			$page_total=$dbo->totalPage;
		}else{
			$result_rs=$dbo->{$get_type}($sql);
		}
	}
     
	return $result_rs;
}



// vim600:ts=4 st=4 foldmethod=marker foldmarker=<<<,>>>
// vim600:syn=php commentstring=//%s
?>
